package com.ahui;

import org.springframework.util.StringUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author : ph.li
 * @date : 2023/8/21 17:40
 */
public class MyTest {

    public static void main(String[] args) {

        String str = "I1";
        Pattern pattern = Pattern.compile("^[^1-5]*(?:(?<!\\d)([1-5])\\D*)?"); // 匹配只包含最多一个1-5中间的数字
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            String matchStr = matcher.group(1);
            if (matchStr != null) {
                // 匹配到了数字，添加到新字符串中
                String[] strs = {"R1", "R2", "R3", "R4", "R5"};
                String newStr = "";
                switch (matchStr) {
                    case "1":
                        newStr = "R1(保守型)";
                        break;
                    case "2":
                        newStr = "R2(稳健型)";
                        break;
                    case "3":
                        newStr = "R3(平衡型)";
                        break;
                    case "4":
                        newStr = "R4(成长型)";
                        break;
                    case "5":
                        newStr = "R5(进取型)";
                        break;
                    default:
                        break;
                }
                System.out.println(newStr); // 输出新字符串
            } else {
                System.out.println("没有找到匹配的数字");
            }
        } else {
            System.out.println("不符合要求");
        }
    }


}
